package cn.xshi.bpm.web;

import cn.hutool.core.collection.CollectionUtil;
import cn.xshi.bpm.design.ImgXmlEntity;
import cn.xshi.bpm.design.MxGraphModel;
import cn.xshi.bpm.design.MxGraphToBase64;
import cn.xshi.bpm.param.LcImgParam;
import cn.xshi.bpm.param.NodeAttributeParam;
import cn.xshi.bpm.service.*;
import cn.xshi.bpm.util.Constant;
import cn.xshi.bpm.vo.*;
import com.github.pagehelper.PageInfo;
import cn.xshi.common.annotation.Auth;
import cn.xshi.common.base.*;
import cn.xshi.common.util.*;
import cn.xshi.bpm.model.LcApply;
import cn.xshi.bpm.model.LcDeploymentHis;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import cn.xshi.common.entity.OauthAccountEntity;
import cn.xshi.common.util.file.FileUtil;
import cn.xshi.bpm.model.LcNodeAttribute;
import cn.xshi.bpm.param.LcProcessParam;
import cn.xshi.bpm.util.ActivitiUtil;
import cn.xshi.bpm.model.LcProcess;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
import org.activiti.bpmn.model.EndEvent;
import org.activiti.bpmn.model.UserTask;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @Desc 流程管理
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Api(value = "流程管理",description = "流程管理", tags = "流程管理（包含流程设计，部署，发布等）")
@RestController
@RequestMapping("/lcProcess")
@Slf4j
public class LcProcessController  extends BaseAction {

	@Resource
	private LcProcessService lcProcessService;

	@Resource
    ActivitiUtil activitiUtil;

	@Resource
	private LcApplyService lcApplyService;

	@Resource
	private LcDeploymentHisService lcDeploymentHisService;

	@Resource
	private LcNodeAttributeService lcNodeAttributeService;

	@Resource
	private LcTaskService lcTaskService;

	/**
	 * 查询并分页
	 * @param baseSearch
	 */
	@ApiOperation(value="查询并分页", notes="查询并分页")
	@PostMapping(value="/list")
	@Auth(value = "/lcProcess/list",authenticationType = Auth.AuthorizationType.REQUIRED_LOGIN_NOT_AUTH)
	public BasePage<List<LcProcess>> getLcProcessBListByCondition(@RequestBody BaseSearch baseSearch){
		Map<String, Object> condition = baseSearch.convert();
		commonHPager(baseSearch);
		List<LcProcess> lcProcessList = lcProcessService.getLcProcessListByCondition(condition);
		for(LcProcess lcProcess:lcProcessList){
			if(!StringUtil.isEmpty(lcProcess.getCreateId())){
				OauthAccountEntity createBy = getAccount(lcProcess.getCreateId());
				if(null != createBy){
					lcProcess.setCreateBy(createBy.getName());
				}
			}
			if(!StringUtil.isEmpty(lcProcess.getUpdateId())){
				OauthAccountEntity modifiedBy = getAccount(lcProcess.getUpdateId());
				if(null != modifiedBy){
					lcProcess.setModifiedBy(modifiedBy.getName());
				}
			}
		}
		PageInfo<LcProcess> page = new PageInfo<LcProcess>(lcProcessList);
		return outPageBootStr(page,baseSearch);
	}

	/**
	 * 查询单条记录
	 * @param id
	 */
	@ApiOperation(value="查询单条记录", notes="查询单条记录")
	@GetMapping(value="/get/{id}")
	@Auth(value = "/lcProcess/get",authenticationType = Auth.AuthorizationType.REQUIRED_LOGIN_NOT_AUTH)
	public BaseResult<LcProcess> getLcProcessById(@PathVariable("id")String id){
		LcProcess lcProcess = lcProcessService.getLcProcessById(id);
		if(!StringUtil.isEmpty(lcProcess.getCreateId())){
			OauthAccountEntity createBy = getAccount(lcProcess.getCreateId());
			if(null != createBy){
				lcProcess.setCreateBy(createBy.getName());
			}
		}
		if(!StringUtil.isEmpty(lcProcess.getUpdateId())){
			OauthAccountEntity modifiedBy = getAccount(lcProcess.getUpdateId());
			if(null != modifiedBy){
				lcProcess.setModifiedBy(modifiedBy.getName());
			}
		}
		return outDataStr(lcProcess);
	}

	/**
	 * 添加
	 * @param lcProcess
	 */
	@ApiOperation(value="添加", notes="添加")
	@PostMapping(value="/add")
	public BaseResult addLcProcess(@RequestBody LcProcess lcProcess){
		int i = 0;
		if(null != lcProcess){
			lcProcess.setId(toUUID());
			i=lcProcessService.addLcProcess(lcProcess);
		}
		if(i>0){
			return outAudStr(true);
		}else{
			return outAudStr(false);
		}
	}

	/**
	 * 修改
	 * @param lcProcess
	 */
	@ApiOperation(value="修改", notes="修改")
	@PutMapping(value="/update")
	public BaseResult updateLcProcess(@RequestBody LcProcess lcProcess){
		int i = 0;
		if(null != lcProcess){
			i=lcProcessService.updateLcProcess(lcProcess);
		}
		if(i>0){
			return outAudStr(true);
		}else{
			return outAudStr(false);
		}
	}

	/**
	 * 删除
	 * @param id
	 */
	@ApiOperation(value="删除", notes="删除")
	@DeleteMapping(value="/delete")
	public BaseResult delLcProcess(String id){
		int i = 0;
		if(!StringUtil.isEmpty(id)){
			Map<String, Object> condition = new HashMap<String, Object>();
			condition.put("id",id.split(","));
			i=lcProcessService.delLcProcess(condition);
		}
		if(i>0){
			return outAudStr(true);
		}else{
			return outAudStr(false);
		}
	}

	/**
	 * 通过在线设计生成流程信息
	 * @param mxGraphModel
	 * @param request
	 * @param response
	 * @return
	 */
	@ApiOperation(value="在线设计", notes="通过在线设计生成流程信息")
	@PostMapping(value="/create")
	public BaseResult<LcProcess> create(@RequestBody MxGraphModel mxGraphModel, HttpServletRequest request, HttpServletResponse response){
		return lcProcessService.create(mxGraphModel,request,response);
	}

	/**
	 * 部署流程
	 * @param lcProcess
	 * @return
	 */
	@ApiOperation(value="部署流程", notes="部署流程")
	@PutMapping(value="/createDeployment")
	public BaseResult createDeployment(@RequestBody LcProcess lcProcess){
		Map<String, Object> condition = new HashMap<String, Object>();
		condition.put("id", lcProcess.getId());
		condition.put("status", 1);
		condition.put("updateId",getCurrentAccountId());
		condition.put("updateTime",getDate());
		int i = lcProcessService.updateLcProcessStatus(lcProcess.getId(), condition);
		if(i>0){
			return outAudStr(true);
		}else{
			return outAudStr(false);
		}
	}

	/**
	 * 获取所有实例
	 * @param lc_deployment_his_id
	 * @return
	 */
	@ApiOperation(value="获取所有实例", notes="获取所有实例")
	@GetMapping(value="/getProcessInstance")
	public BaseResult getProcessInstance(String lc_deployment_his_id){
		ProcessDefinition processDefinition = activitiUtil.getProcessDefinition(lc_deployment_his_id);
		List<ProcessInstance> list = activitiUtil.getProcessInstaceListById(processDefinition.getId());
		JSONArray jsonArray = new JSONArray();
		Map<String, Object> model = new HashMap<String, Object>();
		for(int i = 0; i < list.size(); i++){
			ProcessInstance processInstance = list.get(i);
			model.put("id", processInstance.getId());
			model.put("name",processInstance.getName()) ;
			model.put("processDefinitionName", processInstance.getProcessDefinitionName());
			model.put("processDefinitionVersion", processInstance.getProcessDefinitionVersion());
			if(processInstance.isSuspended()){
				model.put("suspended", "是");
			}else{
				model.put("suspended", "否");
			}
			if(activitiUtil.isEnded(processInstance.getId())){
				model.put("pstatus", "已结束");
			}else{
				model.put("pstatus", "运行中");
			}
			model.put("description", processInstance.getDescription());
			model.put("processDefinitionId", processInstance.getProcessDefinitionId());
			model.put("processDefinitionKey", processInstance.getProcessDefinitionKey());
			jsonArray.add(model);
		}
		return outItemsStr(jsonArray);
	}

	/**
	 * 根据taskId高亮图
	 * @param taskId
	 * @return
	 */
	@ApiOperation(value="根据taskId高亮图", notes="根据taskId高亮图")
	@GetMapping(value = "/view/image/{taskId}")
	@Auth(value = "/lcProcess/view/image",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult getImageByTaskId(@PathVariable("taskId")String taskId){
		BaseResult baseResult = new BaseResult();
		try {
			HistoricTaskInstance historicTaskInstance = activitiUtil.getTaskById(taskId);
			String definitionId = historicTaskInstance.getProcessDefinitionId();
			LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisByDeploymentId(definitionId);
			List<ActivityImplEntity> activityImplEntities = activitiUtil.getImageByInstance(historicTaskInstance.getProcessInstanceId());
			ActivityImplImageEntity activityImplImageEntity = new ActivityImplImageEntity(lcDeploymentHis.getMxgraphXml(),lcDeploymentHis.getMxgraphStyle(),activityImplEntities);
			baseResult.setData(activityImplImageEntity);
		}catch (Exception e){
			log.error("根据taskId高亮图异常，{}",e);
			throw new ExceptionUtil("根据taskId高亮图异常,异常信息："+e.getMessage());
		}
		return baseResult;
	}

	/**
	 * 根据实例id高亮图
	 * @param processInstanceId
	 * @return
	 */
	@ApiOperation(value="根据实例id高亮图", notes="根据实例id高亮图")
	@GetMapping(value = "/image/{processInstanceId}")
	@Auth(value = "/lcProcess/image",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult getImageByInstance(@PathVariable("processInstanceId")String processInstanceId){
		BaseResult baseResult = new BaseResult();
		try {
			ProcessDefinition processDefinition = activitiUtil.getProcessDefinitionByInstanceId(processInstanceId);
			String deploymentId = processDefinition.getDeploymentId();
			List<ActivityImplEntity> activityImplEntities = activitiUtil.getImageByInstance(processInstanceId);
			LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisByDeploymentId(deploymentId);
			ActivityImplImageEntity activityImplImageEntity = new ActivityImplImageEntity(lcDeploymentHis.getMxgraphXml(),lcDeploymentHis.getMxgraphStyle(),activityImplEntities);
			baseResult.setData(activityImplImageEntity);
			baseResult.setSuccess(true);
		}catch (Exception e){
			log.error("根据实例id高亮图异常，{}",e);
			throw new ExceptionUtil("根据实例id高亮图异常,异常信息："+e.getMessage());
		}
		return baseResult;
	}

	/**
	 * 根据流程部署编号+申请编号查找流程图
	 * @param deploymentId
	 * @throws Exception
	 */
	@ApiOperation(value="根据流程部署编号+申请编号查找流程图", notes="根据流程部署编号+申请编号查找流程图")
	@Auth(value = "/lcProcess/image/deployment/apply",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	@RequestMapping(value="/image/{deploymentId}/{lcApplyId}")
	public BaseResult getImageByDeploymentId(@PathVariable("deploymentId")String deploymentId,@PathVariable("lcApplyId")String lcApplyId){
		BaseResult baseResult = new BaseResult();
		Map<String,Object> map = new HashMap<>();
		// 从仓库中找需要展示的文件
		List<String> names = activitiUtil.getRepositoryService().getDeploymentResourceNames(deploymentId);
		String imageName = null;
		for (String name : names) {
			if(name.indexOf(".png")>=0){
				imageName = name;
			}
		}
		if(imageName!=null){
			LcApply lcApply = lcApplyService.getLcApplyById(lcApplyId);
			if(lcApply != null){
				Map<String, Object> condition = new HashMap<String, Object>();
				LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisNewUnique(condition);
				LcProcess lcProcess = lcProcessService.getLcProcessById(lcDeploymentHis.getLcProcessId());
				String attachPath = FileUtil.validOrCreateFile(getSysPathCache(Constant.ACTIVITI_LC).get(0).getPath()+lcProcess.getTitle()+"/"+lcProcess.getImgPath());
				String base64 = Base64Util.imgToBase64ByLocal(attachPath);
				map.put("image",base64);
				baseResult.setData(map);
			}
		}
		return baseResult;
	}

	/**
	 * 根据申请编号查找流程图
	 * @param lcApplyId
	 * @throws Exception
	 */
	@ApiOperation(value="根据申请编号查找流程图", notes="根据申请编号查找流程图")
	@Auth(value = "/lcProcess/viewImage",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	@RequestMapping(value="/viewImage/{lcApplyId}")
	public BaseResult getImageByLcApplyId(@PathVariable("lcApplyId")String lcApplyId){
		LcApply lcApply = lcApplyService.getLcApplyById(lcApplyId);
		BaseResult baseResult = new BaseResult();
		Map<String,Object> map = new HashMap<>();
		if(lcApply != null){
			Map<String, Object> condition = new HashMap<String, Object>();
			LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisNewUnique(condition);
			LcProcess lcProcess = lcProcessService.getLcProcessById(lcDeploymentHis.getLcProcessId());
			String attachPath = FileUtil.validOrCreateFile(getSysPathCache(Constant.ACTIVITI_LC).get(0).getPath()+lcProcess.getTitle()+"/"+lcProcess.getImgPath());
			String base64 = Base64Util.imgToBase64ByLocal(attachPath);
			map.put("image",base64);
			baseResult.setData(map);
		}
		return baseResult;
	}

	/**
	 * 挂起流程实例（可作为撤销流程）
	 * @param id
	 * @return
	 */
	@ApiOperation(value="挂起流程实例", notes="挂起流程实例")
	@GetMapping(value="/suspendProcessInstanceById")
	public BaseResult suspendProcessInstanceById(String id){
		boolean flag = activitiUtil.suspendProcessInstanceById(id);
		return outAudStr(flag);
	}

	/**
	 * 激活流程实例(开启流程实例)
	 * @param id
	 * @return
	 */
	@ApiOperation(value="激活流程实例", notes="激活流程实例")
	@GetMapping(value="/activateProcessInstanceById")
	public BaseResult activateProcessInstanceById(String id){
		boolean flag = activitiUtil.activateProcessInstanceById(id);
		return outAudStr(flag);
	}

	/**
	 * 完成任务
	 * @return
	 */
	@ApiOperation(value="完成任务", notes="完成任务")
	@GetMapping(value="/completeTask")
	public BaseResult completeTask(String taskId){
		return outAudStr(activitiUtil.completeTask(taskId));
	}

	/**
	 * 下载Bpmn文件
	 * @param lc_process_id
	 * @param response
	 */
	@ApiOperation(value="下载Bpmn文件", notes="下载Bpmn文件")
	@GetMapping(value="/downFileBpmn")
	@Auth(value = "/lcProcess/downFileBpmn",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public void downFile(String lc_process_id, HttpServletResponse response){
		LcProcess lcProcess = lcProcessService.getLcProcessById(lc_process_id);
		String versionPath = "";
		if(null != lcProcess.getVersion()){
			versionPath = lcProcess.getVersion()+"/";
		}
		response.setContentType("text/html;charset=utf-8");
		String attachPath = FileUtil.validOrCreateFile(getSysPathCache(Constant.ACTIVITI_LC).get(0).getPath()+lcProcess.getTitle()+"/"+versionPath+lcProcess.getImgPath());
		File file = new File(attachPath);
		String attachmentPath=lcProcess.getBpmnPath();
		try {
			if(!file.exists()){
				response.getWriter().println("<script>window.parent.toastrBoot(3,'文件不存在');</script>");
			}else{
				int len=0;
				byte []buffers = new byte[1024];
				BufferedInputStream br = null;
				OutputStream ut = null;
				response.reset();
				response.setContentType("application/x-msdownload");
				response.setHeader("Content-Disposition","attachment;filename=" +java.net.URLEncoder.encode(attachmentPath,"UTF-8"));
				br = new BufferedInputStream(new FileInputStream(file));
				ut = response.getOutputStream();
				while((len=br.read(buffers))!=-1){
					ut.write(buffers, 0, len);
				}
				ut.flush();
				ut.close();
				br.close();
			}
		} catch (IOException e) {
			log.error("下载Bpmn文件异常，{}",e);
		}
	}

	/**
	 * 下载image文件
	 * @param id
	 * @param response
	 */
	@ApiOperation(value="下载image文件", notes="下载image文件")
	@GetMapping(value="/downFileImg")
	@Auth(value = "/lcProcess/downFileImg",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public void downFileImg(String id,HttpServletResponse response){
		LcProcess lcProcess = lcProcessService.getLcProcessById(id);
		String versionPath = "";
		if(null != lcProcess.getVersion()){
			versionPath = lcProcess.getVersion()+"/";
		}
		response.setContentType("text/html;charset=utf-8");
		String attachPath = FileUtil.validOrCreateFile(getSysPathCache(Constant.ACTIVITI_LC).get(0).getPath()+lcProcess.getTitle()+"/"+versionPath+lcProcess.getImgPath());
		File file = new File(attachPath);
		String attachmentPath=lcProcess.getImgPath();
		try {
			if(!file.exists()){
				response.getWriter().println("<script>window.parent.toastrBoot(3,'文件不存在');</script>");
			}else{
				int len=0;
				byte []buffers = new byte[1024];
				BufferedInputStream br = null;
				OutputStream ut = null;
				response.reset();
				response.setContentType("application/x-msdownload");
				response.setHeader("Content-Disposition","attachment;filename=" +java.net.URLEncoder.encode(attachmentPath,"UTF-8"));
				br = new BufferedInputStream(new FileInputStream(file));
				ut = response.getOutputStream();
				while((len=br.read(buffers))!=-1){
					ut.write(buffers, 0, len);
				}
				ut.flush();
				ut.close();
				br.close();
			}
		} catch (IOException e) {
			log.error("下载image文件异常，{}",e);
		}
	}

	/**
	 * 根据taskId高亮图返回base64图片流
	 * @param taskId
	 * @param response
	 * @return
	 */
	@ApiOperation(value="根据taskId高亮图返回base64图片流", notes="根据taskId高亮图返回base64图片流")
	@GetMapping(value = "/view/base64/image/{taskId}")
	@Auth(value = "/lcProcess/view/base64/image/task",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult getImageBase64ByTaskId(@PathVariable("taskId")String taskId,HttpServletRequest request, HttpServletResponse response){
		BaseResult baseResult = new BaseResult();
		try {
			HistoricTaskInstance historicTaskInstance = activitiUtil.getTaskById(taskId);
			if(null == historicTaskInstance){
				log.info("未能查找到流程实例,任务编号：{}",taskId);
				baseResult.setSuccess(false);
				baseResult.setMessage("未能查找到流程实例");
				return baseResult;
			}
			String lcDeploymentHisId = activitiUtil.getDeploymentIdByTaskId(taskId);
			LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisByDeploymentId(lcDeploymentHisId);
			if(null == lcDeploymentHis){
				log.info("未能查找到部署对象,流程部署编号：{}",lcDeploymentHisId);
				baseResult.setSuccess(false);
				baseResult.setMessage("未能查找到部署对象");
				return baseResult;
			}
			List<ActivityImplEntity> activityImplEntities = activitiUtil.getImageByInstance(historicTaskInstance.getProcessInstanceId());
			MxGraphToBase64 mxGraphToBase64 = new MxGraphToBase64();
			String imgXml = lcDeploymentHis.getImgXml();
			ImgXmlEntity imgXmlEntity = null;
			String base64 = null;

			if(!CollectionUtil.isEmpty(activityImplEntities)){
				List<String> idList = new ArrayList<>();
				for(ActivityImplEntity activityImplEntity: activityImplEntities){
					idList.add(activityImplEntity.getId());
				}
				imgXmlEntity = mxGraphToBase64.doImgXml(imgXml,idList);
				String xml = imgXmlEntity.getImgXml();
				BufferedImage bufferedImage = mxGraphToBase64.imageXmlBase64(request.getRequestURI(),xml,lcDeploymentHis.getW(),lcDeploymentHis.getH(),response);
				base64 = "data:image/png;base64," +Base64Util.toBase64(bufferedImage);
			}

			baseResult.setData(new ActivityImplImageEntity(base64,activityImplEntities));
		}catch (Exception e){
			log.error("根据taskId高亮图异常，{}",e);
		}
		return baseResult;
	}

	/**
	 * 根据processInstanceId高亮图返回base64图片流
	 * @param processInstanceId
	 * @param response
	 * @return
	 */
	@ApiOperation(value="根据processInstanceId高亮图返回base64图片流", notes="根据processInstanceId高亮图返回base64图片流")
	@GetMapping(value = "/view/base64/image/instance/{processInstanceId}")
	@Auth(value = "/lcProcess/view/base64/image/instance",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult getImageBase64ByProcessInstanceId(@PathVariable("processInstanceId")String processInstanceId,HttpServletRequest request, HttpServletResponse response){
		BaseResult baseResult = new BaseResult();
		try {
			ProcessInstance processInstance = activitiUtil.getProcessInstanceById(processInstanceId);
			if(null == processInstance){//流程实例结束情况直接读取流程完成的流程图
				ProcessDefinition processDefinition = activitiUtil.getProcessDefinitionByInstanceId(processInstanceId);
				String deploymentId = processDefinition.getDeploymentId();
				LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisByDeploymentId(deploymentId);
				if(null == lcDeploymentHis){
					log.info("未能查找到流程部署对象");
					baseResult.setSuccess(false);
					baseResult.setMessage("未能查找到流程部署对象");
					return baseResult;
				}
				LcProcess lcProcess = lcProcessService.getLcProcessById(lcDeploymentHis.getLcProcessId());
				if(null == lcProcess){
					log.info("未能查找到流程对象");
					baseResult.setSuccess(false);
					baseResult.setMessage("未能查找到流程对象");
					return baseResult;
				}
				MxGraphToBase64 mxGraphToBase64 = new MxGraphToBase64();
				BufferedImage bufferedImage = mxGraphToBase64.imageXmlBase64(request.getRequestURI(),lcProcess.getImgXml(),lcProcess.getW(),lcProcess.getH(),response);
				String base64 = "data:image/png;base64," + Base64Util.toBase64(bufferedImage);
				baseResult.setData(new ActivityImplImageEntity(base64,null));
				return baseResult;
			}
			String lcDeploymentHisId = processInstance.getDeploymentId();
			LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisByDeploymentId(lcDeploymentHisId);
			if(null == lcDeploymentHis){
				log.info("未能查找到部署对象,流程部署编号：{}",lcDeploymentHisId);
				baseResult.setSuccess(false);
				baseResult.setMessage("未能查找到部署对象");
				return baseResult;
			}
			List<ActivityImplEntity> activityImplEntities = activitiUtil.getImageByInstance(processInstanceId);
			MxGraphToBase64 mxGraphToBase64 = new MxGraphToBase64();
			String imgXml = lcDeploymentHis.getImgXml();
			ImgXmlEntity imgXmlEntity = null;
			String base64 = null;

			if(!CollectionUtil.isEmpty(activityImplEntities)){
				List<String> idList = new ArrayList<>();
				for(ActivityImplEntity activityImplEntity: activityImplEntities){
					idList.add(activityImplEntity.getId());
				}
				imgXmlEntity = mxGraphToBase64.doImgXml(imgXml,idList);
				String xml = imgXmlEntity.getImgXml();
				BufferedImage bufferedImage = mxGraphToBase64.imageXmlBase64(request.getRequestURI(),xml,lcDeploymentHis.getW(),lcDeploymentHis.getH(),response);
				base64 = "data:image/png;base64," +Base64Util.toBase64(bufferedImage);
			}

			baseResult.setData(new ActivityImplImageEntity(base64,activityImplEntities));
		}catch (Exception e){
			log.error("根据processInstanceId高亮图返回Base64图片流异常，{}",e);
		}
		return baseResult;
	}

	/**
	 * 根据流程模板id查找流程图base64
	 * @param id
	 * @param request
	 * @param response
	 * @return
	 */
	@ApiOperation(value="根据流程模板id查找流程图base64", notes="根据流程模板id查找流程图base64")
	@GetMapping(value = "/image/base64/{id}")
	@Auth(value = "/lcProcess/image/base64/id",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult getImageBase64ByProcessId(@PathVariable("id")String id, HttpServletRequest request, HttpServletResponse response){
		BaseResult baseResult = new BaseResult();
		try {
			LcProcess lcProcess = lcProcessService.getLcProcessById(id);
			if(null == lcProcess){
				log.info("未能查找到流程对象，id：{}",id);
				baseResult.setSuccess(false);
				baseResult.setMessage("未能查找到流程对象");
				return baseResult;
			}
			MxGraphToBase64 mxGraphToBase64 = new MxGraphToBase64();
			BufferedImage bufferedImage = mxGraphToBase64.imageXmlBase64(request.getRequestURI(),lcProcess.getImgXml(),lcProcess.getW(),lcProcess.getH(),response);
			String base64 = "data:image/png;base64," + Base64Util.toBase64(bufferedImage);
			baseResult.setData(base64);
		}catch (Exception e){
			log.error("查找到流程对象异常，{}",e);
		}
		return baseResult;
	}

	/**
	 * 根据流程模板id及节点属性查找流程图base64
	 * @param id 流程模板id
	 * @param lcImgParamList
	 * @param request
	 * @param response
	 * @return
	 */
	@ApiOperation(value="根据流程模板id及节点属性查找流程图base64", notes="根据流程模板id及节点属性查找流程图base64")
	@PostMapping(value = "/image/attr/{id}")
	@Auth(value = "/lcProcess/image/attr/id",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult getActImgByProId(@PathVariable("id")String id, @RequestBody List<LcImgParam> lcImgParamList, HttpServletRequest request, HttpServletResponse response){
		BaseResult baseResult = new BaseResult();
		try {
			LcProcess lcProcess = lcProcessService.getLcProcessById(id);
			if(null == lcProcess){
				log.info("未能查找到流程对象，id：{}",id);
				baseResult.setSuccess(false);
				baseResult.setMessage("未能查找到流程对象");
				return baseResult;
			}

			List<String> idList = new ArrayList<>();
			if(!CollectionUtil.isEmpty(lcImgParamList)){
				for(LcImgParam lcImgParam: lcImgParamList){
					idList.add(lcImgParam.getActivityId());
				}
			}
			MxGraphToBase64 mxGraphToBase64 = new MxGraphToBase64();
			ImgXmlEntity imgXmlEntity = mxGraphToBase64.doImgXml(lcProcess.getImgXml(),idList);
			String xml = imgXmlEntity.getImgXml();
			BufferedImage bufferedImage = mxGraphToBase64.imageXmlBase64(request.getRequestURI(),xml,lcProcess.getW(),lcProcess.getH(),response);
			String base64 = "data:image/png;base64," +Base64Util.toBase64(bufferedImage);
			baseResult.setData(base64);
		}catch (Exception e){
			log.error("查找到流程对象异常，{}",e);
		}
		return baseResult;
	}

	/**
	 * 根据流程定义id查询发起表单数据
	 * @param processDefinitionId
	 * @return
	 */
	@ApiOperation(value="查询开始表单数据", notes="根据流程定义id查询发起表单数据")
	@GetMapping(value="/form/{processDefinitionId}")
	@Auth(value = "/lcProcess/form",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult getStartFormData(@PathVariable("processDefinitionId") String processDefinitionId){
		return new BaseResult(activitiUtil.getStartFormData(processDefinitionId));
	}

	/**
	 * 根据流程定义id查询发起表单数据
	 * @param processDefinitionId
	 * @return
	 */
	@ApiOperation(value="查询开始表单数据", notes="根据流程定义id查询发起表单数据")
	@GetMapping(value="/formProperties/{processDefinitionId}")
	@Auth(value = "/lcProcess/formProperties",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult getStartFormProperties(@PathVariable("processDefinitionId") String processDefinitionId){
		return new BaseResult(activitiUtil.getStartFormProperties(processDefinitionId));
	}

	/**
	 * 根据流程模块Key查找最新流程版本
	 * @param moduleKey
	 * @return
	 */
	@ApiOperation(value="查询最新流程版本", notes="根据流程模块Key查找最新流程版本")
	@GetMapping(value="/business/{moduleKey}")
	@Auth(value = "/lcProcess/business/moduleKey",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult<LcDeploymentHis> getHisProcess(@PathVariable("moduleKey") String moduleKey){
		LcProcess lcProcess = lcProcessService.getLcProcessByModuleKey(moduleKey);
		if(null == lcProcess){
			return new BaseResult("未能获取到模块key",false,null);
		}
		Map<String,Object> condition = new HashMap<>();
		condition.put("lcProcessId",lcProcess.getId());
		LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisNewUnique(condition);
		return new BaseResult(lcDeploymentHis);
	}

	/**
	 * 根据模块Key查询发起人所在节点及发起人所在节点的下个节点（查询最新部署）
	 * @param moduleKey
	 * @return
	 */
	@ApiOperation(value="根据模块Key查询发起人所在节点及发起人所在节点的下个节点（查询最新部署）", notes="根据模块Key查询发起人所在节点及发起人所在节点的下个节点（查询最新部署）")
	@GetMapping(value="/attribute/{moduleKey}")
	@Auth(value = "/lcProcess/attribute/moduleKey",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult<LcAttributeEntityCurrent> getLcAttributeByModuleKey(@PathVariable("moduleKey") String moduleKey){
		return lcTaskService.getLcAttributeByModuleKey(moduleKey);
	}

	/**
	 * 根据模块Key+版本号查询发起人所在节点及发起人所在节点的下个节点（查询最新部署）
	 * @param moduleKey
	 * @return
	 */
	@ApiOperation(value="根据模块Key+版本号查询发起人所在节点及发起人所在节点的下个节点（查询最新部署）", notes="根据模块Key+版本号查询发起人所在节点及发起人所在节点的下个节点（查询最新部署）")
	@GetMapping(value="/attribute/{moduleKey}/{version}")
	@Auth(value = "/lcProcess/attribute/moduleKey/version",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult<LcAttributeEntityCurrent> getLcAttributeByModuleKey(@PathVariable("moduleKey") String moduleKey, @PathVariable("version") String version){
		return lcTaskService.getLcAttributeByModuleKey(moduleKey,version);
	}

	/**
	 * 复制
	 * @param lcProcessParam
	 */
	@ApiOperation(value="复制", notes="复制")
	@PostMapping(value="/copy")
	public BaseResult copy(@RequestBody LcProcessParam lcProcessParam, HttpServletRequest request, HttpServletResponse response){
		return lcProcessService.copy(lcProcessParam,request,response);
	}

	/**
	 * 流程树
	 */
	@GetMapping(value="/tree")
	@Auth(value = "/lcProcess/tree",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	@ApiOperation(value="流程树", notes="流程树")
	public BaseResult getProcessList(LcProcess lcProcessPar){
		Map<String, Object> condition = new HashMap<String, Object>();
		if(!StringUtil.isEmpty(lcProcessPar.getTitle())){
			condition.put("title",lcProcessPar.getTitle());
		}
		if(!StringUtil.isEmpty(lcProcessPar.getLcProductId())){
			condition.put("lcProductId",lcProcessPar.getLcProductId());
		}
		if(!StringUtil.isEmpty(lcProcessPar.getLcGroupId())){
			condition.put("lcGroupId",lcProcessPar.getLcGroupId());
		}
		if(!StringUtil.isEmpty(lcProcessPar.getTitle())){
			condition.put("status",lcProcessPar.getStatus());
		}
		List<BaseJSTreeEntity> list = new ArrayList<BaseJSTreeEntity>();
		List<LcProcess> lcProcesses = lcProcessService.getLcProcessListByCondition(condition);
		if(!CollectionUtil.isEmpty(lcProcesses)){
			for(LcProcess lcProcess: lcProcesses){
				BaseJSTreeEntity baseJSTreeEntity = new BaseJSTreeEntity();
				baseJSTreeEntity.setId(lcProcess.getId());
				baseJSTreeEntity.setParent("0");
				baseJSTreeEntity.setText(lcProcess.getTitle());
				baseJSTreeEntity.setSingleClickExpand(true);
				baseJSTreeEntity.setTempObject("P");
				list.add(baseJSTreeEntity);
			}
			List<LcDeploymentHis> lcDeploymentHisList = lcDeploymentHisService.getLcDeploymentHisListByCondition(condition);
			if(!CollectionUtil.isEmpty(lcDeploymentHisList)){
				for(LcDeploymentHis lcDeploymentHis: lcDeploymentHisList){
					BaseJSTreeEntity baseJSTreeEntity = new BaseJSTreeEntity();
					baseJSTreeEntity.setId(lcDeploymentHis.getId());
					baseJSTreeEntity.setParent(lcDeploymentHis.getLcProcessId());
					baseJSTreeEntity.setText("版本-"+lcDeploymentHis.getVersion());
					baseJSTreeEntity.setSingleClickExpand(true);
					baseJSTreeEntity.setTempObject("C");
//					baseJSTreeEntity.setIcon("fa fa-folder m--font-danger");
					baseJSTreeEntity.setIcon("fa fa-folder");
					list.add(baseJSTreeEntity);
				}
			}
		}
		BaseJSTreeEntity baseJSTreeEntity = new BaseJSTreeEntity();
		List<BaseJSTreeEntity> baseJSTreeEntitiesList = baseJSTreeEntity.buildTree(list,"0");
		/*根目录则显示方法
		BaseJSTree baseJSTree = new BaseJSTree("部门",baseJSTreeEntitiesList,new BaseJSTreeStateEntity(false,false,false));
		return new BaseResult(baseJSTree);
		*/
		return new BaseResult(JsonUtil.toFastJson(baseJSTreeEntitiesList));
	}

	/**
	 *
	 * @param nodeId
	 * @param mountsId
	 * @return
	 */
	private LcNodeAttribute getLcNodeAttribute(String nodeId,String mountsId){
		NodeAttributeParam nodeAttributeParam = new NodeAttributeParam();
		nodeAttributeParam.setNodeId(nodeId);
		nodeAttributeParam.setMountsId(mountsId);
		LcNodeAttribute lcNodeAttribute = lcNodeAttributeService.getLcNodeAttribute(nodeAttributeParam);
		return lcNodeAttribute;
	}

	/**
	 * 根据主流程id查询任务节点集合
	 * @param id
	 * @return
	 */
	@ApiOperation(value="查询任务节点集合", notes="根据主流程id查询任务节点集合")
	@PostMapping(value = "/userTasks/{id}")
	@Auth(value = "/lcProcess/userTasks",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult<List<LcNodeAttribute>> getTaskNodeList(@PathVariable("id")String id){
		List<LcNodeAttribute> lcNodeAttributes = new ArrayList<>();
		if(StringUtil.isEmpty(id)){
			return new BaseResult();
		}
		LcProcess lcProcess = lcProcessService.getLcProcessById(id);
		if(null != lcProcess){
			List<UserTask> userTasks = activitiUtil.getUserTaskElementsByBpmn(lcProcess.getBpmn());
			for(UserTask userTask:userTasks){
				LcNodeAttribute lcNodeAttribute = new LcNodeAttribute();
				lcNodeAttribute.setNodeId(userTask.getId());
				lcNodeAttribute.setNodeName(userTask.getName());
				lcNodeAttribute.setLcProcessTitle(lcProcess.getTitle());
				lcNodeAttribute.setLcProcessId(lcProcess.getId());
				lcNodeAttribute.setMountsId(lcProcess.getId());
				lcNodeAttribute.setNodeType(ActivitiUtil.USER_TASK);
				LcNodeAttribute nodeAttribute = getLcNodeAttribute(userTask.getId(),lcProcess.getId());
				if(null != nodeAttribute){
					lcNodeAttribute.setId(nodeAttribute.getId());
					lcNodeAttribute.setInitiator(nodeAttribute.getInitiator());
					lcNodeAttribute.setOrderNumber(nodeAttribute.getOrderNumber());
				}else{
					lcNodeAttribute.setOrderNumber(0);
				}
				if(activitiUtil.validateNodeIsMultiInstance(userTask)){
					lcNodeAttribute.setMulti("20");
				}else{
					lcNodeAttribute.setMulti("10");
				}
				lcNodeAttributes.add(lcNodeAttribute);
			}
			SortUtil.Sort(lcNodeAttributes, "orderNumber", "asc");
			List<EndEvent> endEvents = activitiUtil.getEventElementsByBpmn(lcProcess.getBpmn());
			for(EndEvent endEvent : endEvents){
				LcNodeAttribute lcNodeAttribute = new LcNodeAttribute();
				lcNodeAttribute.setNodeId(endEvent.getId());
				lcNodeAttribute.setNodeName(endEvent.getName());
				lcNodeAttribute.setLcProcessTitle(lcProcess.getTitle());
				lcNodeAttribute.setLcProcessId(lcProcess.getId());
				lcNodeAttribute.setMountsId(lcProcess.getId());
				lcNodeAttribute.setMulti("10");
				lcNodeAttribute.setNodeType(ActivitiUtil.END);
				lcNodeAttributes.add(lcNodeAttribute);
			}
			return new BaseResult(lcNodeAttributes);
		}
		return new BaseResult(lcNodeAttributes);
	}

	/**
	 * 导出流程
	 * @param response
	 * @param id
	 */
	@ApiOperation(value="导出流程", notes="导出流程")
	@GetMapping(value = "/export")
	public void exportProcess(HttpServletResponse response,String id) {
		lcProcessService.exportProcess(response,id);
	}

	/**
	 * 导入流程
	 * @param request
	 * @return
	 */
	@PostMapping(value = "/import")
	public BaseResult importProcess(HttpServletRequest request,HttpServletResponse response) {
		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;//转型为MultipartHttpRequest：
		MultiValueMap<String, MultipartFile> multipartFileMultiValueMap =  multipartRequest.getMultiFileMap();//获取所有文件
		MultipartFile multipartFile = multipartRequest.getFile(Constant.ACT_PROCESS_FILE);//获取指定文件即前端file框name标签
		return lcProcessService.importProcess(request,response,multipartFile);
	}

	/**
	 * 根据模块Key查询所有节点
	 * @param moduleKey
	 * @return
	 */
	@ApiOperation(value="根据模块Key查询所有节点", notes="根据模块Key查询所有节点")
	@GetMapping(value="/node/{moduleKey}")
	@Auth(value = "/lcProcess/node/moduleKey",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult<List<LcNodeAttrEntity>> getNodesByModuleKey(@PathVariable("moduleKey") String moduleKey){
		if(StringUtil.isEmpty(moduleKey)){
			return new BaseResult();
		}
		String[] moduleKeyArray = moduleKey.split(",");
		List<LcNodeAttrEntity> lcNodeAttrEntities = new ArrayList<>();
		if(null != moduleKeyArray){
			for(String key : moduleKeyArray){
				LcNodeAttrEntity lcNodeAttrEntity = new LcNodeAttrEntity();
				lcNodeAttrEntity.setModuleKey(key);
				LcProcess lcProcess = lcProcessService.getLcProcessByModuleKey(key);
				if(null == lcProcess){
					log.info("根据模块Key条件，未能查到流程定义");
					lcNodeAttrEntities.add(lcNodeAttrEntity);
					continue;
				}
				Map<String,Object> condition = new HashMap<>();
				condition.put("lcProcessId",lcProcess.getId());
				LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisMoreAttrNewUnique(key);
				if(null == lcDeploymentHis){
					log.info("未能获取到流程部署,模块Key：{}",moduleKey);
					lcNodeAttrEntities.add(lcNodeAttrEntity);
					continue;
				}
				if(StringUtil.isEmpty(lcDeploymentHis.getBpmn())){
					log.info("未能获取到流程Bpm,模块Key：{}",moduleKey);
					lcNodeAttrEntities.add(lcNodeAttrEntity);
					continue;
				}

				Map<String,Object> condition_ = new HashMap<>();
				condition_.put("hid_",lcDeploymentHis.getId());
				List<LcNodeAttribute> lcNodeAttributes = lcNodeAttributeService.getLcNodeAttributeListByCondition(condition_);
				if(CollectionUtil.isEmpty(lcNodeAttributes)){
					log.info("未能获取到流程节点,模块Key：{}",moduleKey);
					lcNodeAttrEntities.add(lcNodeAttrEntity);
					continue;
				}
				List<LcNodeEntity> lcNodeEntities = new ArrayList<>();
				for(LcNodeAttribute lcNodeAttribute : lcNodeAttributes){
					UserTask userTask = activitiUtil.getUserTask(lcDeploymentHis.getBpmn(),lcNodeAttribute.getNodeId());
					if(null != userTask){
						LcNodeEntity lcNodeEntity = new LcNodeEntity();
						lcNodeEntity.setActivityId(userTask.getId());
						lcNodeEntity.setName(userTask.getName());
						lcNodeEntity.setAttr(lcNodeAttribute.getAttr());
						lcNodeEntities.add(lcNodeEntity);
					}
				}
				lcNodeAttrEntity.setLcNodeEntities(lcNodeEntities);
				lcNodeAttrEntities.add(lcNodeAttrEntity);
			}
		}
		BaseResult baseResult = new BaseResult();
		baseResult.setData(lcNodeAttrEntities);
		return baseResult;
	}

	/**
	 * 根据流程实例id查询所有节点
	 * @param procInstId
	 * @return
	 */
	@ApiOperation(value="根据流程实例id查询所有节点", notes="根据流程实例id查询所有节点")
	@GetMapping(value="/node/list/{procInstId}")
	@Auth(value = "/lcProcess/node/list/procInstId",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult<List<LcNodeAttrEntity>> getNodesByProcInstId(@PathVariable("procInstId") String procInstId){
		if(StringUtil.isEmpty(procInstId)){
			return new BaseResult();
		}
		List<LcNodeAttrEntity> lcNodeAttrEntities = new ArrayList<>();
		LcNodeAttrEntity lcNodeAttrEntity = new LcNodeAttrEntity();

		String deploymentId = activitiUtil.getDeploymentIdByProcInstId(procInstId);

		LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisByDeploymentId(deploymentId);
		if(null == lcDeploymentHis){
			log.info("未能获取到流程部署,流程实例id：{}",procInstId);
			lcNodeAttrEntities.add(lcNodeAttrEntity);
		}
		if(StringUtil.isEmpty(lcDeploymentHis.getBpmn())){
			log.info("未能获取到流程Bpm,流程实例id：{}",procInstId);
			lcNodeAttrEntities.add(lcNodeAttrEntity);
		}
		LcProcess lcProcess = lcProcessService.getLcProcessById(lcDeploymentHis.getLcProcessId());
		if(null != lcProcess){
			lcNodeAttrEntity.setModuleKey(lcProcess.getModuleKey());
		}

		Map<String,Object> condition_ = new HashMap<>();
		condition_.put("hid_",lcDeploymentHis.getId());
		List<LcNodeAttribute> lcNodeAttributes = lcNodeAttributeService.getLcNodeAttributeListByCondition(condition_);
		if(CollectionUtil.isEmpty(lcNodeAttributes)){
			log.info("未能获取到流程节点,流程实例id：{}",procInstId);
			lcNodeAttrEntities.add(lcNodeAttrEntity);
		}
		List<LcNodeEntity> lcNodeEntities = new ArrayList<>();
		for(LcNodeAttribute lcNodeAttribute : lcNodeAttributes){
			UserTask userTask = activitiUtil.getUserTask(lcDeploymentHis.getBpmn(),lcNodeAttribute.getNodeId());
			if(null != userTask){
				LcNodeEntity lcNodeEntity = new LcNodeEntity();
				lcNodeEntity.setActivityId(userTask.getId());
				lcNodeEntity.setName(userTask.getName());
				lcNodeEntity.setAttr(lcNodeAttribute.getAttr());
				lcNodeEntities.add(lcNodeEntity);
			}
		}
		lcNodeAttrEntity.setLcNodeEntities(lcNodeEntities);
		lcNodeAttrEntities.add(lcNodeAttrEntity);
		BaseResult baseResult = new BaseResult();
		baseResult.setData(lcNodeAttrEntities);
		return baseResult;
	}

	/**
	 * 根据流程实例id查询所有节点 批量
	 * @param procInstId
	 * @return
	 */
	@ApiOperation(value="根据流程实例id查询所有节点 批量", notes="根据流程实例id查询所有节点 批量")
	@GetMapping(value="/node/list/batch/{procInstId}")
	@Auth(value = "/lcProcess/node/list/batch/procInstId",authenticationType = Auth.AuthorizationType.NOT_REQUIRED_LOGIN)
	public BaseResult<List<LcNodeAttrEntity>> getNodesBatchByProcInstId(@PathVariable("procInstId") String procInstId){
		if(StringUtil.isEmpty(procInstId)){
			return new BaseResult();
		}
		String[] procInstIdArray = procInstId.split(",");

		List<LcNodeAttrEntity> lcNodeAttrEntities = new ArrayList<>();
		if(null != procInstIdArray){
			for(String key : procInstIdArray){
				LcNodeAttrEntity lcNodeAttrEntity = new LcNodeAttrEntity();

				String deploymentId = activitiUtil.getDeploymentIdByProcInstId(key);

				LcDeploymentHis lcDeploymentHis = lcDeploymentHisService.getLcDeploymentHisByDeploymentId(deploymentId);
				if(null == lcDeploymentHis){
					log.info("未能获取到流程部署,流程实例id：{}",key);
					lcNodeAttrEntities.add(lcNodeAttrEntity);
				}
				if(StringUtil.isEmpty(lcDeploymentHis.getBpmn())) {
					log.info("未能获取到流程Bpm,流程实例id：{}", key);
				}
				LcProcess lcProcess = lcProcessService.getLcProcessById(lcDeploymentHis.getLcProcessId());
				if(null != lcProcess){
					lcNodeAttrEntity.setModuleKey(lcProcess.getModuleKey());
				}
				Map<String,Object> condition_ = new HashMap<>();
				condition_.put("hid_",lcDeploymentHis.getId());
				List<LcNodeAttribute> lcNodeAttributes = lcNodeAttributeService.getLcNodeAttributeListByCondition(condition_);
				if(CollectionUtil.isEmpty(lcNodeAttributes)){
					log.info("未能获取到流程节点,流程实例id：{}",key);
					lcNodeAttrEntities.add(lcNodeAttrEntity);
					continue;
				}
				List<LcNodeEntity> lcNodeEntities = new ArrayList<>();
				for(LcNodeAttribute lcNodeAttribute : lcNodeAttributes){
					UserTask userTask = activitiUtil.getUserTask(lcDeploymentHis.getBpmn(),lcNodeAttribute.getNodeId());
					if(null != userTask){
						LcNodeEntity lcNodeEntity = new LcNodeEntity();
						lcNodeEntity.setActivityId(userTask.getId());
						lcNodeEntity.setName(userTask.getName());
						lcNodeEntity.setAttr(lcNodeAttribute.getAttr());
						lcNodeEntities.add(lcNodeEntity);
					}
				}
				lcNodeAttrEntity.setLcNodeEntities(lcNodeEntities);
				lcNodeAttrEntities.add(lcNodeAttrEntity);
			}
		}
		BaseResult baseResult = new BaseResult();
		baseResult.setData(lcNodeAttrEntities);
		return baseResult;
	}
}
